package chapter15;

import chapter15.generator.Generator;

/**
 * @author : DuJiabao
 * @Date : 2021/3/4 16:05
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class Customer {
  private static long counter = 1;
  private final long id = counter++;

  public Customer() {
  }

  @Override
  public String toString() {
    return "Customer{" +
            "id=" + id +
            '}';
  }

  public static Generator<Customer> generator() {
    // 匿名内部类
    return new Generator<Customer>() {
      @Override
      public Customer next() {
        return new Customer();
      }
    };
  }
}
